#!/usr/bin/env python
# -*- coding:utf-8 -*-
#
#-------------------------------------------------------------------------------
# Name:        module1
# Purpose:
#
# Author:      shoo
#
# Created:     13/06/2011
# Copyright:   (c) shoo 2011
# Licence:     <your licence>
#-------------------------------------------------------------------------------
import logging
from google.appengine.ext import db

class MailAddr(db.Model):
    # key_name:メールアドレス
    num=db.IntegerProperty()
    display_name = db.StringProperty(required=True)

def get_name_addr(addr):
    ma = MailAddr.get_by_key_name(addr)
    if ma:
        return ma.display_name+" <"+addr+">"
    return addr

def get_all_csv():
    q = db.GqlQuery("SELECT * FROM MailAddr order by num")
    r = ""
    for ma in q:
        r+= ma.key().name()+","+ma.display_name+"\n"
    return r

def delete_all():
    q = db.GqlQuery("SELECT * FROM MailAddr")
    results = q.fetch(10000)
    db.delete(results)

def main():
    pass

if __name__ == '__main__':
    main()
